package com.wangzhen.spring.ioc.lifecycle.beandefinition;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.annotation.AnnotatedBeanDefinitionReader;

public class AnnotatedBeanDefinitionReaderDemo {

    public static void main(String[] args) {
        DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
        // 基于java 注解的AnnotationBeanDefinitionReader实现
        AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(factory);
        int beforeRegisterCount = factory.getBeanDefinitionCount();
        // 可以注册一个或者多个组件类 （可以是非@Componment 类）
        reader.register(AnnotatedBeanDefinitionReaderDemo.class);
        int afterRegisterCount = factory.getBeanDefinitionCount();

        System.out.println("加载的BeanDefinition数量为：" + (afterRegisterCount - beforeRegisterCount));
    }
}
